﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using MySql.Data.MySqlClient;
using System.Configuration;

namespace SindSaudeCamadas.Dados
{
    public class galeria
    {
        Conex conexao = new Conex();
        public DataTable carregaGaleriaCarrocel()
        {
            DataTable dt = new DataTable();
            MySqlCommand cmdSQL = new MySqlCommand();
            MySqlDataAdapter daSQL = new MySqlDataAdapter();
            try
            {
                string conex = ConfigurationManager.AppSettings["SindSaude"].ToString();
                cmdSQL.Connection = conexao.retornaConexao(conex);

                cmdSQL.CommandType = CommandType.Text;
                cmdSQL.CommandText = "SELECT a.strNome,a.id,a.strCaminhoImagem,cast(concat('galeria.aspx?a=', a.id) as char) as url FROM tbalbuns a where a.id = 0  order by strData desc limit 6;";

                cmdSQL.Connection.Open();
                daSQL.SelectCommand = cmdSQL;
                daSQL.Fill(dt);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                cmdSQL.Connection.Dispose();
                cmdSQL.Dispose();
                daSQL.Dispose();
            }
            return dt;
        }
    }
}
